package com.atguigu.springboot.controller;

import com.atguigu.springboot.exception.UserNotExsisException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;
import java.util.Map;

@Controller
public class HelloController {

    @RequestMapping("/success")
    public String success(Map<String, Object> map){
        map.put("hello", "<h1>你好2212321321322</h1>");
        map.put("users", Arrays.asList("zhangsan", "lisi", "wangwu"));
        return "success";
    }

    @GetMapping("/hello")
    public String hello(String user){
        if("aaa".equals(user)){
            throw new UserNotExsisException();
        }
        return "Hello World";
    }
}
